var kinds;
Page({
  /**
   * 页面的初始数据
   */
  data: {
    showView: false,
    // curNav: 1,
    curIndex: 0,
    curNav: '全部',
  },

  //事件处理函数 
  changeColor: function (e) {
    // let id = e.target.dataset.id;
    var index = parseInt(e.target.dataset.index);
    var that = this;
    // 获取item项的id，和数组的下标值  
    var id = e.currentTarget.dataset.id;
    var idss = e.currentTarget.dataset.name;
    this.setData({
      curNav: id,
      curIndex:index,
    })
    //  把点击到的某一项，设为当前index
    that.setData({
      showView: (!that.data.showView),
    })

    wx.request({
      url:
      'https://www.cakeyouxuan.com/small/index/erji_goods',
      data: {
        id: idss,
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"  //post
      },
      success: function (res) {
        that.setData({
          goods_list: res.data.goods_list,
        });
        // console.log(res);console.log('在这里');

      },
    })
  },


  sanji: function (event) {
    let id = event.target.dataset.id,
      that = this;
    wx.request({
      url: 'https://www.cakeyouxuan.com/small/index/erji_goods',
      data: {
        id: id,
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"  //post
      },
      success: function (res) {
        var less = id;
        that.setData({
          less:id,
          goods_list: res.data.goods_list,
        });
      },
    })
  }, 
  stap: function (e) {
    var goods = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: "/pages/yiguo/list/list?id=" + goods
    })
  },
  mytouchend: function (e) {
    this.setData({
      currentItemId: e.currentTarget.dataset.num
    })
  },
  onChangeShowState: function () {
    var that = this;
    that.setData({
      showView: (!that.data.showView)
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var kinds = options.kinds;
    var ids = options.ids;  //一级id
    wx.request({
      url: 'https://www.cakeyouxuan.com/small/index/class_good',
      data: {
        id: ids,
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"  //post
      },
      success: function (res) {
        console.log(res);
        that.setData({
          listclass: res.data.listclass,
          goods_list: res.data.goods_list,
        });
      },
    })
    that.setData({
      mername: options.kinds//options为页面路由过程中传递的参数
    })
    wx.setNavigationBarTitle({
      title: that.data.mername//页面标题为路由参数
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})